﻿/*****************************************************************//**
 * @file    FITKAcousticsVTKGraphObjectSEASemiInfFluid.h
 * @brief   Graph object for SEA sub-system semi-infinite-fluid data.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-05
 *********************************************************************/

#ifndef __FITKACOUSTICSVTKGRAPHOBJECTSEASEMIINFFLUID_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTSEASEMIINFFLUID_H__

#include "FITKAcousticsVTKGraphObjectSEASubSystem.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkUnstructuredGrid;
class vtkPoints;
class vtkImageData;

class FITKAcousticsVTKGraphActor;
class FITKGraphActor2D;
class FITKGraphActorImage;

namespace Acoustics
{
    class FITKSEASubSysSemiInfiniteFluid;
    class FITKAbstractSEAFace;
}

namespace Exchange
{
    /**
     * @brief   Graph object for 'SEA sub-system semi-infinite-fluid'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-05
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectSEASemiInfFluid : public FITKAcousticsVTKGraphObjectSEASubSystem
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectSEASemiInfFluid, FITKAcousticsVTKGraphObjectSEASubSystem);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectSEASemiInfFluid);

    public:
        /**
         * @brief   Constructor.
         * @param   semiInfFluid: The sub-system semi-infinite-fluid data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-05
         */
        FITKAcousticsVTKGraphObjectSEASemiInfFluid(Acoustics::FITKSEASubSysSemiInfiniteFluid* semiInfFluid);

        /**
         * @brief   Destructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-05
         */
        ~FITKAcousticsVTKGraphObjectSEASemiInfFluid();

        /**
         * @brief   Update all graph actors.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Highlight the graph actors.[override]
         * @param   type: The shape type need to be highlighted[default]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-07
         */
        void highlight(FITKAcousticsVTKCommons::ShapeType type = FITKAcousticsVTKCommons::ShapeTypeNone, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-07
         */
        void disHighlight() override;

        /**
         * @brief   Update the actor with the camera if necessary.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-06
         */
        void updateByCamera() override;

        /**
         * @brief   Get the bounds of all fixed world size 3D actors.[override]
         * @param   The bounds
         * @return  Has bounds
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-07
         */
        bool getFixedBounds(double* bounds) override;

        /**
         * @brief   Set if the graph object pickable mode.[override]
         * @param   mode: The pickable mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-07
         */
        void setPickMode(FITKAcousticsVTKCommons::ShapePickMode mode) override;

        /**
         * @brief   Enable or disable the scale mode.[override]
         * @param   isOn: Is the mode enabled
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-08
         */
        void setEnableScale(bool isOn) override;

        /**
         * @brief   Update the visibility with data object's visibility.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-12
         */
        void updateVisibility() override;

        /**
         * @brief   Save the post data dict.( Unused )[override]
         * @param   arrayName: The array name of the post data
         * @param   data: The post data
         *          The key is the data object name.
         *          The value is the post value.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void setPostData(QString arrayName, QHash<QString, float> & data) override
        {
            Q_UNUSED(arrayName);
            Q_UNUSED(data);
        }

        /**
         * @brief   Update the color by the data color array in cell data.( Unused )[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void updateByDataColor() override {}

        /**
         * @brief   Update the color by the post data for cell data.( Unused )[override]
         * @param   arrayName: The data array name
         * @param   rangeMin: The min range for the look up table
         * @param   rangeMax: The max range for the look up table
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void updateByPostCellData(QString arrayName, double rangeMin, double rangeMax) override 
        {
            Q_UNUSED(arrayName);
            Q_UNUSED(rangeMin);
            Q_UNUSED(rangeMax);
        }

        /**
         * @brief   Update the color by the NULL post data for cell data.( Unused )[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        void updateByPostNullData() override {}

    private:
        /**
         * @brief   Intialize.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-21
         */
        void init() override;

        /**
         * @brief   Generate the vtkDataSet for the sub-system.[override]
         * @param   subSys: The sub-system semi-infinite-fluid data
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-05
         */
        bool generateDataSet(Acoustics::FITKAbstractSEASubSys* subSys) override;

        /**
         * @brief   Generate the actor with the sub-system data.[override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-05
         */
        void generateGraph() override;

        /**
         * @brief   Internal function, get the center position of the given face's first tiangle.
         * @param   face: The given face
         * @param   seaNodes: The SEA nodes
         * @param   pos: The return position
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-05
         */
        void getFirstTriangleCenterOfTheFace(Acoustics::FITKAbstractSEAFace* face,
            Acoustics::FITKAcousticsDiscNodeList* seaNodes, double* pos);

    private:
        /**
         * @brief   The actor 2D for picture.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-06
         */
        FITKGraphActorImage* m_fActorImg{ nullptr };

        /**
         * @brief   The enabled picture's image dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-07
         */
        vtkImageData* m_picData{ nullptr };

        /**
         * @brief   The enabled picture's image dataset for highlighting.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-07
         */
        vtkImageData* m_picDataHighlight{ nullptr };

        /**
         * @brief   The disable picture's image dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        vtkImageData* m_picDataDisable{ nullptr };

        /**
         * @brief   The disable picture's image dataset for highlighting.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        vtkImageData* m_picDataHighlightDisable{ nullptr };

        /**
         * @brief   The picture position.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-06
         */
        double m_pos3[3]{ 0., 0., 0. };

    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTSEASEMIINFFLUID_H__
